<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Statement Attributes (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Statement Attributes (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Statement Attributes (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="C-Extensions.html" rel="up" title="C Extensions">
<link href="Attribute-Syntax.html" rel="next" title="Attribute Syntax">
<link href="Enumerator-Attributes.html" rel="prev" title="Enumerator Attributes">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en_US">
<div class="section-level-extent" id="Statement-Attributes">
<div class="nav-panel">
<p>
Next: <a href="Attribute-Syntax.html" accesskey="n" rel="next">Attribute Syntax</a>, Previous: <a href="Enumerator-Attributes.html" accesskey="p" rel="prev">Enumerator Attributes</a>, Up: <a href="C-Extensions.html" accesskey="u" rel="up">Extensions to the C Language Family</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Statement-Attributes-1"><span>6.38 Statement Attributes<a class="copiable-link" href="#Statement-Attributes-1"> &para;</a></span></h3>
<a class="index-entry-id" id="index-Statement-Attributes"></a>

<p>GCC allows attributes to be set on null statements.  See <a class="xref" href="Attribute-Syntax.html">Attribute Syntax</a>,
for details of the exact syntax for using attributes.  Other attributes are
available for functions (see <a class="pxref" href="Function-Attributes.html">Declaring Attributes of Functions</a>), variables
(see <a class="pxref" href="Variable-Attributes.html">Specifying Attributes of Variables</a>), labels (see <a class="pxref" href="Label-Attributes.html">Label Attributes</a>), enumerators
(see <a class="pxref" href="Enumerator-Attributes.html">Enumerator Attributes</a>), and for types (see <a class="pxref" href="Type-Attributes.html">Specifying Attributes of Types</a>).
</p>
<dl class="table">
<dt><a id="index-fallthrough-statement-attribute"></a><span><code class="code">fallthrough</code><a class="copiable-link" href="#index-fallthrough-statement-attribute"> &para;</a></span></dt>
<dd><p>The <code class="code">fallthrough</code> attribute with a null statement serves as a
fallthrough statement.  It hints to the compiler that a statement
that falls through to another case label, or user-defined label
in a switch statement is intentional and thus the
<samp class="option">-Wimplicit-fallthrough</samp> warning must not trigger.  The
fallthrough attribute may appear at most once in each attribute
list, and may not be mixed with other attributes.  It can only
be used in a switch statement (the compiler will issue an error
otherwise), after a preceding statement and before a logically
succeeding case label, or user-defined label.
</p>
<p>This example uses the <code class="code">fallthrough</code> statement attribute to indicate that
the <samp class="option">-Wimplicit-fallthrough</samp> warning should not be emitted:
</p>
<div class="example smallexample">
<pre class="example-preformatted">switch (cond)
  {
  case 1:
    bar (1);
    __attribute__((fallthrough));
  case 2:
    ...
  }
</pre></div>

</dd>
<dt><a id="index-assume-statement-attribute"></a><span><code class="code">assume</code><a class="copiable-link" href="#index-assume-statement-attribute"> &para;</a></span></dt>
<dd><p>The <code class="code">assume</code> attribute with a null statement serves as portable
assumption.  It should have a single argument, a conditional expression,
which is not evaluated.  If the argument would evaluate to true
at the point where it appears, it has no effect, otherwise there
is undefined behavior.  This is a GNU variant of the ISO C++23
standard <code class="code">assume</code> attribute, but it can be used in any version of
both C and C++.
</p>
<div class="example smallexample">
<pre class="example-preformatted">int
foo (int x, int y)
{
  __attribute__((assume(x == 42)));
  __attribute__((assume(++y == 43)));
  return x + y;
}
</pre></div>

<p><code class="code">y</code> is not actually incremented and the compiler can but does not
have to optimize it to just <code class="code">return 42 + 42;</code>.
</p>
</dd>
</dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Attribute-Syntax.html">Attribute Syntax</a>, Previous: <a href="Enumerator-Attributes.html">Enumerator Attributes</a>, Up: <a href="C-Extensions.html">Extensions to the C Language Family</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
